package exam.business.service;

import exam.common.constant.ResultPort;
import exam.common.key.KeySubQuestion;
import exam.model.dao.TSubQuestionDAO;
import exam.model.entity.TSubQuestionEntity;
import exam.model.entity.TUserEntity;
import exam.system.business.AbstractService;
import exam.system.business.BusinessServiceInfo;
/**
 * <p>SubQuestionAddService</p>
 * 
 * @author Phong
 * @version 19/5/2012
 */
public class SubQuestionAddService extends AbstractService {
	// tSubQuestionDAO
	TSubQuestionDAO tSubQuestionDAO = new TSubQuestionDAO();
	@Override
	public String executeService(BusinessServiceInfo serviceInfo)
			throws Exception {
		TSubQuestionEntity tSubQuestionEntity = serviceInfo.getObject(KeySubQuestion.T_SUB_QUESTION_ENTITY);
		tSubQuestionEntity.setUserEntity(new TUserEntity(tSubQuestionEntity.getUserId()));
		int insert = tSubQuestionDAO.insertSubQuestion(tSubQuestionEntity);
		if(insert == 0) {
			return ResultPort.FAIL;
		} else {
			return ResultPort.SUCCESS;
		}
	}

}
